<include file="Public:head" />

<!-- 用户资料 -->

<div class="table_box">
  <!-- 筛选 -->
  <form class="layui-form" >
    <fieldset class="layui-elem-field layui-field-title">
      <legend>用户资料设置</legend>
      <div class="layui-field-box">


        <div class="layui-form-item" style="margin-top:20px;">
          <label class="layui-form-label"><span style="color:red">*</span> 我的角色</label>
          <div class="layui-input-inline">
            <input type="title" name="groupname" id="groupname" autocomplete="off"  class="layui-input" value="{$info.groupname}" disabled title="禁止输入">
          </div>
          <div class="layui-form-mid layui-word-aux">角色不可修改哦~</div>
        </div>

        <div class="layui-form-item">
          <label class="layui-form-label"><span style="color:red">*</span> 账号名</label>
          <div class="layui-input-inline">
            <input type="title" name="username" id="username"  autocomplete="off"  class="layui-input" value="{$info.username}">
          </div>
          <div class="layui-form-mid layui-word-aux">登录后台用的啦</div>
        </div>

        <div class="layui-form-item">
          <label class="layui-form-label"><span style="color:red">*</span> 昵称</label>
          <div class="layui-input-inline">
            <input type="title" name="nickname" id="nickname"  autocomplete="off"  class="layui-input" value="{$info.nickname}">
          </div>
          <div class="layui-form-mid layui-word-aux">显示的称谓</div>
        </div>

        <div class="layui-form-item">
          <label class="layui-form-label"><span style="color:red">*</span> 手机</label>
          <div class="layui-input-inline">
            <input type="title" name="phone" id="phone"  autocomplete="off"  class="layui-input" value="{$info.phone}">
          </div>
        </div>

        <div class="layui-form-item">
          <label class="layui-form-label"><span style="color:red">*</span> 邮箱</label>
          <div class="layui-input-inline">
            <input type="title" name="email" id="email"  autocomplete="off"  class="layui-input" value="{$info.email}"> 
          </div>
        </div>


        <div class="layui-form-item">
          <label class="layui-form-label">头像</label>
          <!-- 显示头像 -->
          <div class="layui-input-inline" style="width:100px;">
            <div class="layui-upload">
              <div class="layui-upload-list" style="margin: 0px 0;">
                <img class="layui-upload-img" src="__ROOT__/public/images/{$info.avater}" id="demo1" style="border:1px solid #ccc;width:100px;">
                <p id="demoText"></p>
              </div>
            </div>  
          </div>
          <!-- 上传按钮 -->
          <button type="button" class="layui-btn  layui-btn-sm layui-btn-normal" id="images">
            上传头像
          </button>

        </div>

        <div class="layui-form-item layui-form-text">
          <label class="layui-form-label">备注</label>
          <div class="layui-input-block">
            <textarea placeholder="请输入内容" name='des' class="layui-textarea" style="width:95%" id="des" >{$info.a_des}</textarea>
          </div>
        </div>

      </div>
    </fieldset>
  </form>
  <!--  -->
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn " onclick="sub()">确认修改</button>
    </div>
  </div>


<include file="Public:foot" />



<!-- ---------------------------------------------------------------- -->



<script>
layui.use('upload', function(){
  var $ = layui.jquery
  ,upload = layui.upload;

  var uploadInst = upload.render({
    elem: '#images'
    ,url: '__APP__/api/upload'
    ,method:'post'
    // ,before: function(obj){
    //   //预读本地文件示例，不支持ie8
    //   obj.preview(function(index, file, result){
    //     $('#demo1').attr('src', result); //图片链接（base64）
    //   });
    // }
    ,done: function(res){
      // console.log(res);
      //如果上传失败
      if(res.status == 0){
        return layer.msg('上传失败');
      }else{
        $('#demo1').attr('src', res.data);
      }
    }
    ,error: function(){
      //演示失败状态，并实现重传
      var demoText = $('#demoText');
      demoText.html('<span style="color: #FF5722;">上传失败</span> ');

    }
  });
});



//确定-提交
function sub(){
  var username = $('#username').val();
  var nickname = $('#nickname').val();
  var phone = $('#phone').val();
  var email = $('#email').val();
  var img = $('#demo1').attr('src');
  // alert(img);


  if(username == ''){
      layer.msg('用户名不能为空',{
        time:900  ,           //时间
        offset: '100px' 
      });
      
      $('#username').css('border','1px solid #ff0000');
      var timer = setTimeout(function () {
            $('#username').css('border','1px solid #e6e6e6');
      },1000);
      return false;
  }

  if(nickname == ''){
      layer.msg('昵称不能为空',{
        time:900  ,           //时间
        offset: '100px'
      });
      
      $('#nickname').css('border','1px solid #ff0000');
      var timer = setTimeout(function () {
            $('#nickname').css('border','1px solid #e6e6e6');
      },1000);
      return false;
  }

    if(phone == ''){
      layer.msg('手机不能为空',{
        time:900  ,           //时间
        offset: '100px'
      });
      $('#phone').css('border','1px solid #ff0000');
      var timer = setTimeout(function () {
            $('#phone').css('border','1px solid #e6e6e6');
      },1000);
      return false;
  }
  if(email == ''){
      layer.msg('邮箱不能为空',{
        time:900  ,           //时间
        offset: '100px'
      });
      $('#email').css('border','1px solid #ff0000');
      var timer = setTimeout(function () {
            $('#email').css('border','1px solid #e6e6e6');
      },1000);
      return false;
  }

  
  $.ajax({
      type:"get",
      url:"__APP__/admininfo/edit?avater="+img,
      data:$(".layui-form").serialize(),

      success:function(data){
      	// alert(data);
        returnInfo(data);
      }        
  })
}


</script>



<!-- ---------------------------------------------------------------- -->



